<?php

/*
 * To change this template, choose Tools | Templates
* and open the template in the editor.
*/
require 'connection.php';

try{
	$con = connect();

	$sql = "SELECT c.idciudad, c.nombre FROM ciudad c ORDER BY c.nombre";
	$result = $con->query($sql);

	$arr = array();
	while ($obj = $result->fetch_object()) {
		$arr[] = array('nombre' => utf8_encode($obj->nombre),
				'id' => $obj->idciudad
		);
	}

	mysqli_close($con);

	echo '' . json_encode($arr) . '';
}catch (Exception $e){
	echo $e->getMessage();
}
?>
